home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / stk-3.002 / stk-3 / STk-3.1 / Demos / Widget / Wentry2.stklos < prev    next >
Encoding:
Text File  |  1995-09-13  |  1.7 KB  |  34 lines

  1. ;;;;
  2. ;;;; STk adaptation of the Tk widget demo.
  3. ;;;;
  4. ;;;; This demonstration script is the same as the entry1.tcl script
  5. ;;;; except that it creates scrollbars for the entries.
  6. ;;;;
  7. (require "Tk-classes")
  8.  
  9. (define (demo-entry2)
  10.   (define w (make-demo-toplevel "entry2"
  11.                 "Entry Demonstration (with scrollbars)"
  12.                 "Three different entries are displayed below, with a scrollbar for each entry.  You can add characters by pointing, clicking and typing.  The normal Motif editing characters are supported, along with many Emacs bindings.  For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor.  For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with Shift key and mouse button2 pressed."))
  13.  
  14.   (define (scroll-entry  value)
  15.     (let* 
  16.     ((f (make <Frame>     :parent w))
  17.      (s (make <Scrollbar> :parent f :relief "sunken" :orientation 'h :width 10))
  18.      (e (make <Entry>     :parent f :relief "sunken" :value value)))
  19.       ;; pack entry and scrollbar.
  20.       (pack e s :side "top" :fill "x")
  21.       ;; Associate bindings
  22.       (slot-set! e 'x-scroll-command (lambda l (apply (slot-ref s 'Id) 'set  l)))
  23.       (slot-set! s 'command          (lambda l (apply (slot-ref e 'Id) 'xview l)))
  24.       ;; return the enclosing frame
  25.       f))
  26.  
  27.     (pack (scroll-entry "Initial value")
  28.       (scroll-entry "This entry contains a long value, much too long to fit in the window at one time, so long in fact that you'll have to scan or scroll to see the end.")
  29.       (scroll-entry "")
  30.       :side "top"
  31.       :padx 10
  32.       :pady 10
  33.       :fill "x"))
  34.